package com.cy.device.job;

import com.cy.device.service.DeviceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author: jiangwang
 * @created: 2023/11/7 10:32
 */
@Component
@EnableScheduling
public class ScheduledTask {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private DeviceService deviceService;

    @Scheduled(cron = "0 0/5 * * * ?")
    public void refreshDeviceInfo(){
        logger.info("执行定时任务，重新读取备案的设备信息");
        try {
            deviceService.getDeviceInfo();
        }catch (Exception e){
            logger.error("重新读取备案的设备信息失败：",e);
        }
    }

}
